﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace MvcEngine.Mvc.Results
{
    public class RedirectToActionResult : ActionResult
    {
        public string ActionName { get; set; }

        public override void ExecuteResult(ControllerContext context)
        {
            context.RouteData.Values["actionName"] = ActionName;
            context.RouteData.Values["action"] = ActionName;

            string controller = context.RouteData.GetRequiredString("controller");
            ControllerBuilder.Current.GetControllerFactory().CreateController(context.RequestContext, controller).Execute(context.RequestContext);

        }
    }
}
